package com.jackchong.utils;

import android.app.Activity;
import android.view.View;
import android.view.ViewGroup;

import com.chad.library.adapter.base.provider.BaseItemProvider;
import com.chad.library.adapter.base.util.AdapterUtilsKt;
import com.chad.library.adapter.base.viewholder.BaseViewHolder;

import org.jetbrains.annotations.NotNull;

/**
 * author : jack(黄冲)
 * e-mail : 907755845@qq.com
 * create : 2020/8/26
 * desc   :
 */
abstract public class JProvider<T> extends BaseItemProvider<T> {

    protected Activity mActivity;

    @NotNull
    @Override
    public JRAdapter.ViewHolder onCreateViewHolder(@NotNull ViewGroup parent, int viewType) {
        View itemView = AdapterUtilsKt.getItemView(parent, getLayoutId());
        JAuto.auto(itemView);
        mActivity = (Activity) parent.getContext();
        return new JRAdapter.ViewHolder(itemView);
    }

    @Override
    final public void convert(@NotNull BaseViewHolder baseViewHolder, T t) {
        convert(((JRAdapter.ViewHolder) baseViewHolder), t);
    }

    public abstract void convert(JRAdapter.ViewHolder holder, T item);
}
